<?php
/**
 * Copyright (c) 2018,2345
 * 摘    要：更新程序
 * 作    者：林幸亿
 * 修改日期：2018.04.20
 */

require_once 'libraries/MysqlDbClass.php';
require_once 'libraries/RedisDbClass.php';

$id = null;
//Retrieve the User ID from the Query String URL
if (! empty($_GET['id'])) 
{
    $id = $_REQUEST['id'];
}

//Return to main page if there is no ID
if (null == $id)
{
    header("Location: index.php");
}
else
{    
    //Retrieve the user detail from DB based on user id
    
    $db = Mysqldb::getInstance();

    $sql = "SELECT * FROM users where id = " . $id;
    $data = $db->find($sql);
    
     /*   
    $redis = RedisDb::getInstance();
    $data = $redis->hmget( 'user:' . $id, ['name', 'email', 'mobile']);
    
    $data['name'] = $data[0];
    $data['email'] = $data[1];
    $data['mobile'] = $data[2];
    */
    //die(print_r($data));
}
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <link   href="css/bootstrap.min.css" rel="stylesheet">
    </head>

    <body>
        <div class="container">

            <div class="span10 offset1">
                <div class="row">
                    <h3>用户 User</h3>
                </div>

                <div class="form-horizontal" >
                    <div class="control-group">
                        <label class="control-label">姓名 <br>Name</label>
                        <div class="controls">
                            <label class="checkbox">
<?php echo $data['name']; ?>
                            </label>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">电子邮件 <br>Email Address</label>
                        <div class="controls">
                            <label class="checkbox">
<?php echo $data['email']; ?>
                            </label>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">手机号码 <br>Mobile Number</label>
                        <div class="controls">
                            <label class="checkbox">
<?php echo $data['mobile']; ?>
                            </label>
                        </div>
                    </div>
                    <div class="form-actions">
                        <a class="btn" href="index.php">返回 Back</a>
                    </div>


                </div>
            </div>

        </div> <!-- /container -->
    </body>
</html>